/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utilidades;

import beans.CandidatoBean;
import dao.CandidatoDAO;
import javax.faces.bean.ViewScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author programador
 */

@FacesConverter(value="candidatoConverter")
@ViewScoped
public class CandidatoConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
        
       CandidatoDAO candidatoDAO = new CandidatoDAO();
       CandidatoBean candidatoBean = candidatoDAO.getCandidatoEspecifico(string);
       return candidatoBean;
        
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object o) {
        
       CandidatoBean candidatoBean = new CandidatoBean();
       candidatoBean = (CandidatoBean)o;
       return candidatoBean.getNome();
        
    }
    
}